package job_center

import (
	"context"
	pb "git.mycaigou.com/gfyx/micro-gfyx-oppty-service/proto/micro_gfyx_oppty_service_proto/micro-gfyx-oppty-service/job_center"
	"git.mycaigou.com/gfyx/micro-gfyx-oppty-service/service/job_center"
	"git.myscrm.cn/golang/stark/v4"
)

type jobCenterServer struct {
	jobService job_center.JobCenterServiceIface
}

func NewJobCenterServer(
	jobService job_center.JobCenterServiceIface,
) pb.JobCenterServiceServer {
	return &jobCenterServer{
		jobService: jobService,
	}
}

func (s *jobCenterServer) GetMyJobList(ctx context.Context, request *pb.GetMyJobListRequest) (*pb.GetMyJobListResponse, error) {
	resp, err := s.jobService.MyJobList(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc GetMyJobList request:%+v, err:%s", request, err.Error())
		return nil, err
	}
	return resp, nil
}

func (s *jobCenterServer) RerunJob(ctx context.Context, request *pb.RerunJobRequest) (*pb.RerunJobResponse, error) {
	resp, err := s.jobService.RerunJob(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc RerunJob request:%+v, err:%s", request, err.Error())
		return nil, err
	}
	return resp, nil
}
